package com.ruoyi.tsjData.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.pad.ChartLineDTO;
import com.ruoyi.tsjData.domain.pad.TshjTaskReqDTO;
import com.ruoyi.tsjData.domain.plat.DataTshjHj;
import com.ruoyi.tsjData.domain.result.DataTshjResult;
import com.ruoyi.tsjData.service.IDataTshjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.ExecutionException;

/**
 * 提升机-测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/all")
@Api(value="提升机-测试",tags = "提升机-测试接口")
public class DataTshjController extends BaseController
{

    @Autowired
    public IDataTshjService dataTshjService;

    /**
     * 查询此提升机任务的所有测试项目数据
     */
    @PreAuthorize("@ss.hasPermi('tsjData:task:query')")
    @GetMapping("/{dataTaskId}")
    @ApiOperation(value="查询此提升机任务的所有测试项目数据")
    @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long")
    public AjaxResult getDetailTshj(@PathVariable("dataTaskId") Long dataTaskId) throws InterruptedException, ExecutionException {
        TshjTaskReqDTO tshjTaskReqDTO = dataTshjService.getDetailTshj(dataTaskId);
        return AjaxResult.success(tshjTaskReqDTO);
    }

    /**
     * 更新提升机任务测试项数据
     */
    @PreAuthorize("@ss.hasPermi('tsjData:task:update')")
    @PostMapping("/updateDetailTshj")
    @ApiOperation(value="更新此提升机任务的所有测试项目数据")
    public AjaxResult updateDetailTshj(@ApiParam(name="测试项目数据",value="传入json格式",required=true)@RequestBody TshjTaskReqDTO tshjTaskReqDTO) {
        return toAjax(dataTshjService.updateDetailTshj(tshjTaskReqDTO));
    }

    /**
     * 删除此提升机任务的所有测试项目数据
     */
    @DeleteMapping("/{dataTaskId}")
    @ApiOperation(value="删除此提升机任务的所有测试项目数据")
    public AjaxResult deleteAllTask(@PathVariable("dataTaskId") Long[] dataTaskId) {
        int res = dataTshjService.delAllTsjData(dataTaskId);
        return toAjax(res);
    }


    /**
     * 保存提升机测试结果
     */
    @ApiOperation(value="保存提升机测试结果")
    @PostMapping("/dataTshjResult")
    public AjaxResult dataTshjResult(@ApiParam(name="测试项目结果数据",value="传入json格式",required=true)@RequestBody DataTshjResult dataTshjResult){
        return AjaxResult.success(dataTshjService.dataTshjResult(dataTshjResult));
    }

    /**
     * 保存的提升机数据导入报告
     */
    @PreAuthorize("@ss.hasPermi('tsjData:import:query')")
    @PostMapping("/dataTshjImportReport")
    @ApiOperation(value="保存的提升机数据导入报告")
    public AjaxResult dataTshjImportReport(@ApiParam(name="测试项目结果数据",value="传入json格式",required=true)@RequestBody DataTshjResult dataTshjResult){
        return AjaxResult.success(dataTshjService.dataTshjImportReport(dataTshjResult));
    }

}
